package de.hauschild.gmltracer.gml.impl.value.real;

import de.hauschild.gmltracer.gml.Environment;
import de.hauschild.gmltracer.gml.TokenStack;
import de.hauschild.gmltracer.gml.impl.AbstractToken;

public abstract class TwoRealOperatorToken extends AbstractToken {

  @Override
  public void evaluate(final Environment environment, final TokenStack tokenStack) {
    final RealToken second = tokenStack.pop(RealToken.class);
    final RealToken first = tokenStack.pop(RealToken.class);

    final Double result = compute(first.getValue(), second.getValue());
    tokenStack.push(new RealToken(result));
  }

  protected abstract Double compute(final Double first, final Double second);

}
